<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        function compare(arr){
            for(var i=0;i<arr.length;i++)
            {
                for(var j=arr.length;j>i;j--)
                {   
                    if(arr[j]<arr[j-1])
                    {
                        var a=arr[j];
                        arr[j]=arr[j-1];
                        arr[j-1]=a;
                    }

                }
            }
            console.log(arr);
        }
        compare([1,8,2,6,4,3,15,7,9,10,5,100])
    </script>
</body>
</html>